<template>
  <div id="app">
    <h2>测试题</h2>
    <SubjectItem @value="valueFn" id="1"></SubjectItem>
    <SubjectItem @value="valueFn" id="2"></SubjectItem>
    <SubjectItem @value="valueFn" id="3"></SubjectItem>
    <SubjectItem @value="valueFn" id="4"></SubjectItem>
    <SubjectItem @value="valueFn" id="5"></SubjectItem>

    <div>
      <FlagItem :arr="newArr"></FlagItem>
    </div>
  </div>
</template>

<script>
import SubjectItem from "./components/SubjectItem.vue";
import FlagItem from "./components/FlagItem.vue";
export default {
  components: {
    SubjectItem,
    FlagItem,
  },
  created() {
    for (let i = 1; i <= 5; i++) {
      this.newArr.push({
        id: i,
        name: "未完成",
      });
    }
  },
  data() {
    return {
      arr: [],
      newArr: [],
    };
  },
  mounted() {},
  methods: {
    valueFn(value, index) {
      this.newArr[index - 1].name = value;
      // console.log(value, index);
    },
  },
};
</script>

<style>
body {
  background-color: #eee;
}

#app {
  background-color: #fff;
  width: 500px;
  margin: 50px auto;
  box-shadow: 3px 3px 3px rgba(0, 0, 0, 0.5);
  padding: 2em;
}
</style>
